package com.huluobo.h3weekdemo.main

import androidx.lifecycle.MutableLiveData
import com.huluobo.h3weekdemo.base.BaseViewModel

/**
 *  Created by LC on 2023/10/31.
 */
class MainViewModel : BaseViewModel() {
    val repo = MainRepo()
    val success = MutableLiveData<TabBeanResult>()
    val failed = MutableLiveData<String>()

    val getNewsSuccess = MutableLiveData<NewBeanResult>()
    val getNewsFailed = MutableLiveData<String>()

    //fragment需要请求的id,新闻分类的id
    var typeId = MutableLiveData<Int>()

    fun setTypeId(id: Int) {
        typeId.value = id
    }

    fun getMainTabs() {
        repo.getMainTabs(success, failed)
    }

    fun getNews(
        currentPage: Int,
        id: Int,
        pageSize: Int,
    ) {
        repo.getNews(currentPage, id, pageSize, getNewsSuccess, getNewsFailed)
    }
}